<?php

class demo{

    public $pdo;
    public $row;
    public $count;
    public function __construct()
    {
        try{
            $this->pdo = new PDO("mysql:host=localhost;dbname=fenx",'root','root');
        }catch(Exception $e){
            echo $e->getMessage();
        }
        $sql = "select count(*) from tbl_jigou";
        $this->count = $this->pdo->query($sql)->fetchColumn();      //获得总条数
    }

    public function showlist($uppage=1,$downpage=2){//起始页 显示条数
        if($uppage==false){
            $uppage=1;
        }
        $uppage = $uppage*$downpage-$downpage;            //设定每页起始页
        $sql = "select * from tbl_jigou limit {$uppage},{$downpage}";
        $res = $this->pdo->query($sql);
        $this->row=$res->fetchAll();
        return $this->row;
    }


}

